/*
 * test_playermgr.cpp
 *
 *  Created on: Dec 8, 2013
 *      Author: killerg
 */

#include "share/patterns.h"

#include <functional>
#include <list>
#include <set>
#include <string>

using namespace std;

struct player_t {
    int64_t id;
};

struct playermgr {
    typedef function<void(player_t*)> load_cb_t;
    typedef function<void(bool)> create_cb_t;
    struct op_t {
        list<load_cb_t> load_cb;
        list<create_cb_t> create_cb;
    };

    bool player_load(int64_t playerid, load_cb_t cb);
    bool player_create(int64_t playerid, create_cb_t cb);

    player_t* get_online(int64_t playerid);
    player_t* get_loaded(int64_t playerid);


    set<string> name_creating;
    map<string, int64_t> name_lookup;

    ptr_map<int64_t, op_t*> op;

    ptr_map<int64_t, player_t*> online;
    ptr_map<int64_t, player_t*> cached;
};

struct clientsession {
    int64_t id;
    void on_connect();
    void on_disconnect();
};

struct sessmgr {
    ptr_map<int64_t, clientsession*> authed;
    list<clientsession*> unauthed;
};

void handle_auth();
void handle_load();
void handle_create();

bool test_playermgr() {
    return true;
}
